-
-
Notifications
You must be signed in to change notification settings - Fork 221
Glasgow | 25-ITP-SEP | Shreef Ibrahim | Sprint 3 | Coursework #717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Glasgow | 25-ITP-SEP | Shreef Ibrahim | Sprint 3 | Coursework #717
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start on this sprint's tasks, most of it is really good. I have spotted a few areas where you could improve code further
// write one test at a time, and make it pass, build your solution up methodically | ||
// just make one change at a time -- don't rush -- programmers are deep and careful thinkers | ||
function getCardValue(card) { | ||
let rank = card.length === 1 ? card : card.slice(0, -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What circumstances would you have a card of length 1? A card in this case is always a rank + a symbol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What circumstances would you have a card of length 1? A card in this case is always a rank + a symbol
Thanks for pointing that. I checked that if the card is a single character (length 1) for example, "A" it returns 10 which is not true , because this line ( let rank = card.length === 1 ? card: card.slice(0, -1); ) is handling the case where the card is only one character long, Instead of the card should always include both the rank and the suit.
i have updated the function.
}); | ||
// Case 3: Handle Face Cards (J, Q, K): | ||
test("should return the value 10, a card with a rank of ('10', 'J', 'Q', or 'K')", () => { | ||
const aceofSpades = getCardValue("K"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment I gave above - This is a king, but which king, hearts? spades?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, i updated
if (last2Digit >= 11 && last2Digit <= 13) { | ||
return num + "th"; | ||
} | ||
if (las1Digit === 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you have a long series of if checks like this, is there another conditional structure that might be more appropriate to use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated that one using switch case i thnk is more appropiate.
} | ||
|
||
module.exports = passwordValidator; | ||
if (oldPassword.includes(password)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you simplify this final check?
… unnecessary length check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. These changes look good to me.I just have one very minor additional suggestion.
// write one test at a time, and make it pass, build your solution up methodically | ||
// just make one change at a time -- don't rush -- programmers are deep and careful thinkers | ||
function getCardValue(card) { | ||
let rank = card.slice(0, -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way you could simplify this slice even more?
(Hint: You can achieve the same thing with only one argument to slice)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not really thinking about the card length - I was more thinking about the .slice
function itself. Here you are passing 2 arguments, 0
and -1
. Did you know you can call .slice
with only a single argument?
Self checklist
Her is JavaScript challenges tasks covering running test, error fixing, code interpretation, and a stretch exploration activity.